import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";

// https://vitejs.dev/config/
export default defineConfig({
	plugins: [react()],
	server: {
		// 配置代理
		proxy: {
			"/api": {
				//服务器
				target: "https://xscqa.cqupt.edu.cn/question/",
				changeOrigin: true,
				rewrite: (path) => path.replace(/^\/api/, ""),
			},
			"/authserver": {
				target: "https://ids.cqupt.edu.cn:443/",
				changeOrigin: true,
			},
			"/static": {
				target: "https://xscqa.cqupt.edu.cn/question/img/",
				changeOrigin: true,
			},
		},
	},
	// 配置别名
	resolve: {
		alias: {
			"@": path.resolve(__dirname, "src"),
			components: path.resolve(__dirname, "src/components"),
			styles: path.resolve(__dirname, "src/styles"),
			plugins: path.resolve(__dirname, "src/plugins"),
			views: path.resolve(__dirname, "src/views"),
			layouts: path.resolve(__dirname, "src/layouts"),
			utils: path.resolve(__dirname, "src/utils"),
			api: path.resolve(__dirname, "src/api"),
		},
	},
});
